#import cgi
#import wsgiref.handlers
#
#from google.appengine.api import users
#from google.appengine.ext import db
#from google.appengine.ext import webapp
#from google.appengine.ext.webapp import template

from google.appengine.ext.db import djangoforms

from django.http import HttpResponse
from dvk.main.models.e_numbers import ENumber
#from dvk.main.models.e_numbers import *

class ENumberForm(djangoforms.ModelForm):
    class Meta:
        model   = ENumber
        exclude = ['update_time']

from django.shortcuts import render_to_response

def e_number(request):
    if (request.method == 'POST'):
        return HttpResponse('post', mimetype='text/plain')
    else:
        form = ENumberForm()
        return render_to_response('contact_form.html', {'form': form})
        #return HttpResponse('get', mimetype='text/plain')

#  def post(self):
#    data = ItemForm(data=self.request.POST)
#    if data.is_valid():
#      # Save the data, and redirect to the view page
#      entity = data.save(commit=False)
#      entity.added_by = users.get_current_user()
#      entity.put()
#      self.redirect('/items.html')
#    else:
#      # Reprint the form
#      self.response.out.write('<html><body>'
#                              '<form method="POST" '
#                              'action="/intl/ru/">'
#                              '<table>')
#      self.response.out.write(data)
#      self.response.out.write('</table>'
#                              '<input type="submit">'
#                              '</form></body></html>')